﻿using UnityEngine;
using UnityEngine.UI;
using QFramework;

namespace HKTools
{
    public enum TipType
    {
        Continue,
        FullScore,
        NotFullScore
    }

    public class HK_UI_QuizTipsPanel : MonoBehaviour, IController
    {
        public IArchitecture GetArchitecture()
        {
            return HK_ArchitectureProvider.Architecture;
        }

        public Text tips_Txt;
        public Button left_Btn;
        public Button right_Btn;

        public void ShowTipsPanel(string msg, string leftBtnName, string rightBtnName, TipType tipType)
        {
            gameObject.SetActive(true);
            tips_Txt.text = msg;

            left_Btn.GetComponentInChildren<Text>().text = leftBtnName;
            right_Btn.GetComponentInChildren<Text>().text = rightBtnName;

            switch (tipType)
            {
                case TipType.Continue:
                    left_Btn.gameObject.SetActive(true);
                    right_Btn.gameObject.SetActive(true);
                    left_Btn.onClick.AddListener(OnClickContinue);
                    right_Btn.onClick.AddListener(OnClickGiveUp);
                    break;
                case TipType.FullScore:
                    left_Btn.gameObject.SetActive(false);
                    right_Btn.gameObject.SetActive(true);
                    right_Btn.onClick.AddListener(OnQuizComplete);
                    break;
                case TipType.NotFullScore:
                    left_Btn.gameObject.SetActive(true);
                    right_Btn.gameObject.SetActive(true);
                    left_Btn.onClick.AddListener(OnCheckWrongItem);
                    right_Btn.onClick.AddListener(OnQuizComplete);
                    break;
                default:
                    break;
            }
        }

        void OnClickContinue()
        {
            gameObject.SetActive(false);
        }

        void OnClickGiveUp()
        {
            gameObject.SetActive(false);
            this.SendEvent<HK_QuizGiveUp_Event>();
        }

        void OnQuizComplete()
        {
            gameObject.SetActive(false);
            this.SendEvent<HK_QuizComplete_Event>();
        }

        void OnCheckWrongItem()
        {
            this.SendEvent<HK_ShowWrongQuesItem>();
        }
    }
}